package com.ea.common.SA;

import com.ea.common.SA.pojo.dto.VideoAnalyzeProcess;
import com.ea.common.SA.pojo.entity.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@FeignClient(
        name = "sentiment-analysis-pro",
        url = "${lb.url}/sentiment-analysis-pro"
)

public interface SAFeign {

    Integer success = 1000;

    @GetMapping("/file/list")
    List<String> listUploadedFiles();

    @PostMapping("/file/getUploadedFileURL")
    Result<String> getUploadedFileURL(@RequestParam("uuid") String uuid);

    @PostMapping("/file/getUploadedFileMeta")
    Result<VideoFileMeta> getUploadedFileMeta(@RequestParam("uuid") String uuid);

    @PostMapping("/file/getPersonVideoList")
    Result<List<SysVideo>> getPersonVideoList(@RequestParam("person_id") Long person_id);

    @PostMapping("/file/getVibraResultByUUID")
    Result<VibraResult> getVibraResultByUUID(@RequestParam("uuid") String uuid);

    @PostMapping("/file/getShenshiResultByUUID")
    Result<ShenshiResult> getShenshiResultByUUID(@RequestParam("uuid") String uuid);

    @PostMapping("/file/getVideoAnalyzeProcessByUUID")
    Result<VideoAnalyzeProcess> getVideoAnalyzeProcessByUUID(@RequestParam("uuid") String uuid);

    @PostMapping("/file/getVideoAnalyzeProcessByID")
    Result<VideoAnalyzeProcess> getVideoAnalyzeProcessByID(@RequestParam("id") Long id);


    /**
     * @return file's uuid
     * @throws IOException exception
     */
    @PostMapping("/file/upload")
    Result<String> handleFileUpload(@RequestParam("file") MultipartFile file,
                                    @RequestParam("person_id") Long person_id) throws IOException;


    @GetMapping("/file/{filename:.+}")
    @ResponseBody
    ResponseEntity<Resource> serveFile(@PathVariable String filename);

    @PostMapping("/RealtimeAnalyze/start")
    ResponseEntity<StartResult> startRealtimeAnalyze();

    @PostMapping("/RealtimeAnalyze/stop")
    ResponseEntity stopRealtimeAnalyze(@RequestBody Integer port);
}
